﻿using M;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MClient
{
    public class DI
    {
        public static IServiceProvider InsProvider { get; private set; }

        static DI()
        {
            Configure();
        }

        private static void Configure()
        {
            var services = new ServiceCollection();

            services.AddDbContext<OneToOneContext>((opt) =>
            {
                string connStr = "Host=127.0.0.1;Port=5432;Database=efsimple;User ID=postgres;Password=sa*123;Pooling=true;MinPoolSize=10;MaxPoolSize=50;";
                opt.UseNpgsql(connStr);
                opt.LogTo(Console.WriteLine)
                    .EnableSensitiveDataLogging();
            });


            services.AddDbContext<MContext>((opt) =>
            {
                string connStr = "Host=127.0.0.1;Port=5432;Database=efsimple;User ID=postgres;Password=sa*123;Pooling=true;MinPoolSize=10;MaxPoolSize=50;";
                opt.UseNpgsql(connStr);
                opt.LogTo(Console.WriteLine)
                    .EnableSensitiveDataLogging();
            });


            services.AddDbContext<FilterContext>((opt) =>
            {
                string connStr = "Host=127.0.0.1;Port=5432;Database=efsimple;User ID=postgres;Password=sa*123;Pooling=true;MinPoolSize=10;MaxPoolSize=50;";
                opt.UseNpgsql(connStr);
                opt.LogTo(Console.WriteLine)
                    .EnableSensitiveDataLogging();
            });

            InsProvider = services.BuildServiceProvider();
        }
    }
}